<template>
    <div id="road" @click="change"
      :style="log == 0 ? 'background-color:rgb(245, 245, 245)' : 'background-color: rgba(13, 13, 13, 0.8)'">新建公告</div>
    <div id="login-box" :style="log == 0 ? 'display:none' : 'display:block;zIndex:40'">
      <form action="">
        <label>公告人:
          <input v-model="id" type="text" placeholder="请输入公告人代码" >
        </label>
        <label>公告内容:
          <input v-model="type" type="text" placeholder="请输入公告内容" >
        </label>
        <label>公告时间:
          <input v-model="mark" type="text" placeholder="2023-08-29T16:00:00.000Z">
        </label>
        
        <button type="button" @click="login">上报</button>
        <p id="close" @click="close">×</p>
      </form>
    </div>
  </template>
    
  <script setup>
  import { applyFilter } from '@turf/turf';
  import { ref, computed } from 'vue'
  import axios from "axios"
  const log = ref(0);
  let active = ref()
  let describe
  let mark
  let mark2='2023-08-29T16:00:00.000Z'
  let id
  
  const change = () => {
    if (log.value == 0) {
      log.value = 1
    } else {
      log.value = 0
    }
  }
  const login = () => {
    axios.get('http://127.0.0.1/notice/addNotice', {
      params: {
        user_id: id,
        notice_content: describe,
        event_describe: mark2,
      }
    }).then(res => {
       console.log(res.data);
       
      if (res.data.status == 200) {
        alert('添加成功')
        log.value = 0
      }
    }).catch(err => {
      console.log("操作失败" + err);
    })
  }
  
  
  const close = () => {
    log.value = 0;
    //清空input中的内容
    describe == ''
    mark == ''
  }
  
  </script>
  <style scoped>
  #road {
    height: 100%;
    width: 150px;
    font-size: 25px;
    color: grey;
    line-height: 80px;
    border-left: 1px solid;
    border-color: gray;
    padding-left: 7px;
    padding-right: 7px;
    align-items: center;
    display: flex;
    justify-content: center;
  
  }
  
  #login-box {
    padding: 20px;
    display: none;
    width: 400px;
    height: 200px;
    display: flex;
    border-radius: 5px;
    position: absolute;
    background-color: #a8a8a8;
    background-image: linear-gradient(0deg, #a8a8a8 90%, #545454 90%, #6d6969 100%);
    margin-left: 700px;
    margin-top: 300px;
    z-index: 200;
  }
  
  #login-box>form {
    text-align: center;
  }
  
  #login-box label {
    display: block;
    font-size: 20px;
    margin: 20px 0 0 0;
  }
  
  #login-box label input {
    width: 200px;
    height: 30px;
  }
  
  #login-box button {
    width: 200px;
    height: 30px;
    margin: 20px 0 0 0;
    width: 90px;
    border-radius: 5px;
  }
  
  #close {
    font-size: 18px;
    position: absolute;
    top: 0;
    right: 5px;
    cursor: pointer;
  }</style>